*********************************************************************************
*** Figure 2
*********************************************************************************

* Project: 	European public opinion twd collective defence
* Authors: 	Matthias Mader
* Date:		Sep 2023	

* Data: VW Project, Post-Ukraine Survey, Pan-European survey (W1)

*********************************************************************************

*** Setup

	clear
	set more off            						// Disable partitioned output
	set dp period									// Use comma instead of dot for decimals
	set linesize 80         						// Line size limit to make output more readable
	macro drop _all         						// clear all macros
	set scheme plotplainblind, permanent				// set graph scheme, e.g., cleanplots, plottig, plotplainblind, burd3, s1mono
	graph set window fontface "Arial"				// set font in graphs | "Arial" | "Times New Roman"


*** Open Dynata data
	use "DATA_clean.dta", clear

*** Alliance orientation
	graph dot ally1_d1_pre ally1_d1_pre2 ally1_d1_post, over(W1_QCOUNTRY, sort(ally1_d1_post) label(labsize(med)) axis(noline) relabel(`r(relabel)')) ///
		name(F2_1, replace) ///
		marker(1, msize(large) msymbol(circle)	mcolor(eltblue%50)) ///
		marker(2, msize(large) msymbol(dot) 	mcolor(eltblue))   /// 
		marker(3, msize(large) msymbol(circle) 	mcolor(red))   /// 
		title("Military alliances should be an essential part" "of [COUNTRY]’s security and defence strategy", size(med)) ///
		yscale(range(0 1)) ylabel(0 "0" .125 " " .25 "25" .375 " " .5 "50" .625 " " .75 "75" .875 " "1 "100", labsize(med)) ///
		ytitle("Agree to military alliances (%)", size(med)) ///
		ylab(,grid) ///
		legend(ring(1) position(6) row(1) order(1 "10/2020" 2 "5/2021" 3 "6/2023") size(med)) ///
		yline(.5) ///  
		plotregion(margin(zero) lcolor(black)) ///
		graphregion(margin(0 5 0 0)) ///
		xsize(3) ysize(3.5)

*** Differences (See Excel file)
	tab W1_QCOUNTRY, sum(ally1_d1_post)
	tab W1_QCOUNTRY, sum(ally1_d1_pre2)
	tab W1_QCOUNTRY, sum(ally1_d1_pre)


*** Willingness to use military force to defend allies
	graph dot policy_LVAsoli_d1_pre policy_LVAsoli_d1_post, over(W1_QCOUNTRY, sort(ally1_d1_post) label(labsize(med)) axis(noline) relabel(`r(relabel)')) ///
		name(F2_2, replace) ///
		marker(1, msize(large) msymbol(circle)	mcolor(eltblue%50)) /// w23: 2022
		marker(2, msize(large) msymbol(circle) 			mcolor(red))   /// w21: 2021
		title("[COUNTRY] should deploy troops" "to secure Latvian borders in Ukraine-type crisis", size(med)) ///
		yscale(range(0 1)) ylabel(0 "0" .125 " " .25 "25" .375 " " .5 "50" .625 " " .75 "75" .875 " "1 "100", labsize(med)) ///
		ytitle("Agree to deploy troops (%)", size(med)) ///
		ylab(,grid) ///
		legend(ring(1) position(6) row(1) order(1 "10/2020" 2 "6/2023") size(med)) ///
		yline(.5) ///  
		plotregion(margin(zero) lcolor(black)) ///
		graphregion(margin(0 5 0 0)) ///
		xsize(3) ysize(3.5)

*** Differences (See Excel file)
	tab W1_QCOUNTRY, sum(policy_LVAsoli_d1_post)
	tab W1_QCOUNTRY, sum(policy_LVAsoli_d1_pre)


*** Correlation
	bysort W1_QCOUNTRY: pwcorr policy_LVAsoli_post ally1_post